package com.xy;

import com.xy.aggregation.College;
import com.xy.iterator.Department;

import java.util.Iterator;
import java.util.List;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/17 20:57
 * @description
 */
public class Output {
    // 学院集合
    private List<College> collegeList;

    public Output(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    /**
     * 输出各个学院的系
     */
    public void printCollege() {
        collegeList.forEach(college -> {
            System.out.println("-------"+college.getName()+"-------");
            printDepartment(college.creteIterator());
        });
    }

    /**
     * 学院输出系
     */
    private void printDepartment(Iterator<Department> iterator) {
        while (iterator.hasNext()) {
            System.out.println(iterator.next().getName());
        }
    }
}
